package com.onepiece.shipelves.common.myutils.queue;

public class ArrayQueue {
    private String[] items;
    private int count;
    private int n;
    private int head;
    private int tail;

    public ArrayQueue(int capacity) {
        items = new String[capacity];
        n = capacity;
    }

    public boolean enqueue(String item){
        if(tail == n){
            return false;
        }
        items[tail] = item;
        ++tail;
        return true;
    }

    public String dequeue(){
        if(head == tail) return null;
        String ret = items[head];
        ++head;
        return ret;
    }
}
